

namespace NodeBasedSkillEditor.Model.Node.RT
{
    public class Node_If_Exe_RT : RT_Node
    {
        public RT_FlowPort FlowIn_RT;

        public RT_SingleValuePort Condition_RT;

        public RT_FlowPort IfTrue_RT;

        public RT_FlowPort IfFalse_RT;

        public Node_If_Exe_RT(Node_If_Exe sourceData, RT_DAG parentDag) : base(sourceData, parentDag)
        {
            FlowIn_RT = new RT_FlowPort(EPortIOType.Input, sourceData.FlowIn, this);

            Condition_RT = new RT_SingleValuePort(EPortIOType.Input, sourceData.Condition, this);

            IfTrue_RT = new RT_FlowPort(EPortIOType.Output, sourceData.IfTrue, this);

            IfFalse_RT = new RT_FlowPort(EPortIOType.Output, sourceData.IfFalse, this);

        }


        public override (EDagExeState, RT_Node) ForewardExecute(DAG_Executor executor)
        {
            bool cond = Condition_RT.GetValue(executor).ToBoolean().Item2;
            if (cond)
            {
                return TryForewardByPort(IfTrue_RT);
            }
            else
            {
                return TryForewardByPort(IfFalse_RT);
            }
        }
    }
}